Skip to content

Add StringWriter#10333

Open
treblereel wants to merge 3 commits into
gwtproject:mainfrom
treblereel:string_writer
Open

Add StringWriter#10333
treblereel wants to merge 3 commits into
gwtproject:mainfrom
treblereel:string_writer

Conversation

@treblereel

Copy link
Copy Markdown
Contributor
  • added a GWT port of StringWriter for compatibility with the J2CL Java emulation layer

ref https://github.com/google/j2cl/blob/master/jre/java/java/io/StringWriter.java

@treblereel treblereel force-pushed the string_writer branch 2 times, most recently from af9b171 to 1df014e Compare June 4, 2026 21:07
- added a GWT port of StringWriter for compatibility with the J2CL Java emulation layer

Signed-off-by: Dmitrii Tikhomirov <chani.liet@gmail.com>
@treblereel

Copy link
Copy Markdown
Contributor Author

hmm, not sure if it's related to this pr

Warning: c] [WARNING] Could not transfer metadata org.gwtproject:gwt:HEAD-SNAPSHOT/maven-metadata.xml from/to sonatype-snapshots (https://central.sonatype.com/repository/maven-snapshots/): status code: 403, reason phrase: Forbidden (403) [exec] Downloading from sonatype-snapshots: https://central.sonatype.com/repository/maven-snapshots/org/gwtproject/gwt/HEAD-SNAPSHOT/gwt-HEAD-SNAPSHOT.pom Error: RROR] [ERROR] Some problems were encountered while processing the POMs: Error: xec] [ERROR] Non-resolvable import POM: The following artifacts could not be resolved: org.gwtproject:gwt:pom:HEAD-SNAPSHOT (absent): Could not transfer artifact org.gwtproject:gwt:pom:HEAD-SNAPSHOT from/to sonatype-snapshots (https://central.sonatype.com/repository/maven-snapshots/): status code: 403, reason phrase: Forbidden (403) @ line 19, column 19 [exec] @ Error: xec] [ERROR] The build could not read 1 project -> [Help 1] Error: xec] [ERROR] Error: xec] [ERROR] The project com.google.gwt.sample.dynatable:dynatable:1.0-SNAPSHOT (/home/runner/work/gwt/gwt/gwt/samples/dynatable/pom.xml) has 1 error Error: xec] [ERROR] Non-resolvable import POM: The following artifacts could not be resolved: org.gwtproject:gwt:pom:HEAD-SNAPSHOT (absent): Could not transfer artifact org.gwtproject:gwt:pom:HEAD-SNAPSHOT from/to sonatype-snapshots (https://central.sonatype.com/repository/maven-snapshots/): status code: 403, reason phrase: Forbidden (403) @ line 19, column 19 -> [Help 2] Error: xec] [ERROR] Error: xec] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. Error: xec] [ERROR] Re-run Maven using the -X switch to enable full debug logging. Error: xec] [ERROR] Error: xec] [ERROR] For more information about the errors and possible solutions, please read the following articles: Error: xec] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException Error: xec] [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

@niloc132 niloc132 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see that j2cl also has ASF sources for this class, contributed in google/j2cl@7a98b9c, but with slightly different contents, and fairly different tests (so I don't think you're attributing Google because you copied it from them?).

@@ -0,0 +1,141 @@
/*
* Copyright 2025 Google Inc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026, GWT project authors

Comment on lines +40 to +42
public void testConstructor() {
assertTrue("Used in tests", true);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why include the test if it doesnt do anything?

@@ -0,0 +1,96 @@
// CHECKSTYLE_OFF: Copyrighted to the Android Open Source Project.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I definitely appreciate the attribution and the fact that there is an apache licensed emul out there we can lean on, two questions:

  • first, this appears simple enough it could just be implemented from scratch, right? the test apparently isnt from asf, so that work had to be done fresh...?
  • second, who is the copyright owner? my read of the copyright notice is that we must list the owner. The content at https://www.apache.org/licenses/LICENSE-2.0.html (almost the link below, but https) says

To apply the Apache License to specific files in your work, attach the following boilerplate declaration, replacing the fields enclosed by brackets "[]" with your own identifying information. (Don't include the brackets!) Enclose the text in the appropriate comment syntax for the file format. We also recommend that you include a file or class name and description of purpose on the same "printed page" as the copyright notice for easier identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

From https://www.apache.org/foundation/license-faq,

Note that the Apache Software Foundation uses a different source header that is related to our use of a CLA. Our instructions for our project's source headers are here.

@niloc132 niloc132 added the ready This PR has been reviewed by a maintainer and is ready for a CI run. label Jun 5, 2026
Signed-off-by: Dmitrii Tikhomirov <chani.liet@gmail.com>
import static javaemul.internal.InternalPreconditions.checkArgument;

/**
* See <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/StringWriter.html">the official

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* See <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/StringWriter.html">the official
* See <a href="https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/StringWriter.html">the official

Maybe latest stable LTS? Alternatively 17 would also make some sense as it's currently the highest possible value of source level for GWT.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, its supersource, so the package and classname is really all we need... More important would be any notes about what makes the GWT impl unique (though this class won't have much of that).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class was taken from j2cl and adapted for gwt. In J2CL, the reference points to java.sun.com (which redirects to Oracle)

But I think that's probably the least significant of the issues that could exist

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I worry about the licensing because it does matter, but the code looks good to me.

If the tests are from google though, they should be attributed as such rather than replace the owner field.

Signed-off-by: Dmitrii Tikhomirov <chani.liet@gmail.com>
@treblereel treblereel requested a review from niloc132 June 8, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready This PR has been reviewed by a maintainer and is ready for a CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants